package com.ctbu.tourism.controller.restful;

import com.ctbu.tourism.entity.Result;
import com.ctbu.tourism.service.LikesService;
import com.ctbu.tourism.utils.ResultUtil;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class LikesController {

    @Autowired
    LikesService likesService;

    @GetMapping("/likes/pid/{pid}")
    Result getLikesPostUids(@PathVariable("pid") Integer pid){
        return ResultUtil.success(likesService.getLikesPostUids(pid));
    }
    @PutMapping("/likes/add")
    Result addLikes(@RequestParam("pid") Integer pid,@RequestParam("uid") Integer uid){
        return ResultUtil.success(likesService.addLikes(pid,uid));
    }

    @DeleteMapping("/likes/reduce")
    Result deleteLikes(@RequestParam("pid") Integer pid,@RequestParam("uid") Integer uid){
        return ResultUtil.success(likesService.deleteLikes(pid,uid));
    }

    @DeleteMapping("/likes/delete")
    Result deleteLikesByPID(@RequestParam("pid") Integer pid){
        return ResultUtil.success(likesService.deleteLikesByPID(pid));
    }

    @GetMapping("/message/likes")
    Result getMessageLikes(@RequestParam("uid") Integer uid){
        return ResultUtil.success(likesService.getMessageByUID(uid));
    }
    @PutMapping("/message/likes/update/status")
    Result updateLikesStatus(@RequestParam("id") Integer id){
        return ResultUtil.success(likesService.updateLikesStatus(id));
    }
}
